package modul.data.lihataktifitas;

import java.util.ArrayList;
import java.util.List;
import javax.swing.table.AbstractTableModel;


public class aktifitasOperatorTabelModel extends AbstractTableModel {

    private List<aktifitasOperator> isi = new ArrayList<aktifitasOperator>();

    public void tambahAktifitas(aktifitasOperator jf) {
        isi.add(jf);
        fireTableRowsInserted(getRowCount(), getColumnCount());
    }

    public void hapusTabel(int i, int row) {
        isi.remove(i);
        fireTableRowsDeleted(i, row);
    }

    public aktifitasOperator getAktifitasOperator(int index) {
        return (aktifitasOperator) isi.get(index);
    }

    @Override
    public int getRowCount() {
        return isi.size();
    }

    @Override
    public int getColumnCount() {
        return 3;
    }

    @Override
    public String getColumnName(int column) {
        switch (column) {
            case 0:
                return "no";
            case 1:
                return "ID Operator";
            case 2:
                return "Waktu";
            default:
                return null;
        }
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        switch (columnIndex) {
            case 0:
                return isi.get(rowIndex).getNo();
            case 1:
                return isi.get(rowIndex).getIdOperator();
            case 2:
                return isi.get(rowIndex).getWaktu();
            default:
                return null;
        }
    }
}
